home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
apidev
/
sc3x04.exe
/
VOLRES.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-02
|
7KB
|
207 lines
// IMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM;
// : :
// : module: volres.c :
// : abstract: This module shows how to make 3.x system calls using :
// : the F2 Shell Interface for the Set Directory Disk :
// : Space Restriction API, obviously it requires the :
// : NetWare Shell. :
// : :
// : This call may need to be made iteratively to return :
// : all of the restriction information. For simplicity, :
// : this example only makes the call once. :
// : :
// : environment: NetWare 3.x v3.11 :
// : Borland C 3.1 :
// : :
// : This software is provided as is and carries no warranty :
// : whatsoever. Novell disclaims and excludes any and all implied :
// : warranties of merchantability, title and fitness for a particular :
// : purpose. Novell does not warrant that the software will satisfy :
// : your requirements or that the software is without defect or error :
// : or that operation of the software will be uninterrupted. You are :
// : using the software at your risk. The software is not a product :
// : of Novell, Inc. or any of subsidiaries. :
// HMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM<
//
// This software is considered pre-release and may be used at your own
// risk and has been provided due to the many requests of our cust-
// omers. Support for this module will be provided at the sole
// discretion of Novell, Inc.
//
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include <fcntl.h>
#include <sys\types.h>
#include <sys\stat.h>
#include "nwsys.c"
//
// First of all, we define the request structure which is needed for the
// Set Directory Disk Space Restriction API call. This structure is
// laid out according to the System Call documentation.
//
struct REQUEST {
WORD sflen; // length of the structure
BYTE sfcode; // the subfunction code
BYTE volNumber; // Volume Number
DWORD objectID;
DWORD diskSpaceLimit;
}Request;
// No reply packet required.
struct REQUESTID {
WORD sfLen; // length of the structure
BYTE sfCode; // subfunction code
BYTE volNumber; // volume number
WORD sequence; // last sequence number
LONG objectID; // bindery object ID
} requestID;
struct REPLY {
WORD sequence; // next sequence number
LONG objectID; // bindery object ID
BYTE accessMask; // trustee access mask
BYTE pathLength; // length of directory path
BYTE path[255]; // directory path
} reply;
struct VOL_REQ {
WORD sfLen;
BYTE sfCode;
BYTE nameLen;
BYTE name[16];
} volNumReq;
struct VOL_REP {
WORD repLength;
BYTE volNumber;
} volNumRep;
struct BIND_REQUEST {
WORD sfLen; // length of the structure
BYTE sfCode; // subfunction code
WORD objectType; // bindery object type
BYTE objectNameLength; // name length: 1 to 47
BYTE objectName[48]; // bindery object name
} binderyRequest;
struct BIND_REPLY {
WORD replyLen; // length of reply buffer
DWORD objectID; // bindery object ID
WORD objectType; // bindery object type
BYTE objectName[48]; // bindery object name
} binderyReply;
WORD NWSystemCall2(BYTE func, // function code
void far *req, // request buffer
void far *rep) // reply buffer
{
union REGS regs;
struct SREGS sregs;
segread(&sregs);
memset(®s, 0, sizeof(regs));
regs.h.ah = func; // AH = function code
regs.x.si = FP_OFF(req); // SI = request buffer offset
regs.x.di = FP_OFF(rep); // DI = reply buffer offset
sregs.ds = FP_SEG(req); // DS = request buffer segment
sregs.es = FP_SEG(rep); // ES = reply buffer segment
intdosx(®s,®s,&sregs); // do the Int 21
return (WORD)regs.h.al; // return code is in AL
}
BYTE GetVolumeNumber(char *volName)
{
int retCode;
volNumReq.sfCode = 0x05;
volNumReq.nameLen = (BYTE) strlen(volName);
memmove((char *) &(volNumReq.name), volName, volNumReq.nameLen);
volNumReq.sfLen = volNumReq.nameLen + 2;
retCode = NWSystemCall2(0xe2, &volNumReq, &volNumRep);
if (retCode) {
printf("Get Volume Number failed. Return code = %d.\n", retCode);
return(255);
}
else
return(volNumRep.volNumber);
}
WORD GetBinderyObjectID(char *userName, WORD objectType, DWORD *objectID)
{
int retCode;
binderyRequest.sfLen = sizeof(binderyRequest);
binderyRequest.sfCode = 0x35;
binderyRequest.objectType = WordSwap(objectType);
binderyRequest.objectNameLength = strlen(userName);
strcpy((char *) &(binderyRequest.objectName), userName);
binderyReply.replyLen = sizeof(binderyReply);
retCode = NWSystemCall2(0xe3, &binderyRequest, &binderyReply);
*objectID = binderyReply.objectID;
return(retCode);
}
int main()
{
int i, retCode, diskNumber;
WORD serverConnectionID, objectType;
DWORD objectID;
BYTE volNumber;
char name[80], buffer[20];
printf("Volume name: ");
gets(name);
volNumber = GetVolumeNumber(name);
if (volNumber == 255)
return(1);
printf("User name: ");
gets(name);
objectType = 1; /* OT_USER */
retCode = GetBinderyObjectID(name, objectType, &objectID);
if (retCode != 0) {
printf("Get Bindery Object ID failed. Return code = %d.\n", retCode);
return(1);
}
Request.sflen = (sizeof Request) ;
Request.sfcode = 0x21; // subfunction code
Request.volNumber = volNumber;
Request.objectID = objectID;
printf("Enter Disk Space Limit: ");
Request.diskSpaceLimit = atol (gets(buffer));
retCode = NWSystemCall(0x16, &Request, sizeof(Request),0,0);
if (retCode == 0)
printf("Disk Space Restriction Successful\n");
else {
printf("Disk Space Restriction failed. Return code = %d.\n",
retCode);
return(1);
}
return(0);
}